/*************************************************************************
	> File Name: test6.cc
	> Author: H.M. Lau
	> Mail: hm.lau@outlook.com
	> Created Time: 2023/09/22 19:23
 ************************************************************************/

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <pthread.h>

void *thread_run(void *args)
{
    pthread_detach(pthread_self());
    printf("%s\n", (char*)args);
    return nullptr;
}

int main(int argc, char *argv[])
{
    pthread_t tid;
    if (pthread_create(&tid, nullptr, thread_run, "thread_run...") != 0) {
        printf("Create thread error\n");
        return 1;
    }
    int ret = 0;
    sleep(1);
    if (pthread_join(tid, nullptr) == 0) {
        printf("pthread wait success\n");
        ret = 0;
    } else {
        printf("pthread wait failed\n");
        ret = 1;
    }
    return ret;
}
